<script>
    function onBridgeReady(){
        if("${tips}".length>0){
            alert("${tips}");
        }
            WeixinJSBridge.invoke(
                'getBrandWCPayRequest', {
                    "appId": "${res.appId}",     //公众号名称，由商户传入
                    "timeStamp": "${res.timeStamp}",         //时间戳，自1970年以来的秒数
                    "nonceStr": "${res.nonceStr}", //随机串
                    "package": "${res.pkg}",
                    "signType": "${res.signType}",         //微信签名方式：
                    "paySign": "${res.paySign}" //微信签名
                },
                function (res) {
                    if (res.err_msg == "get_brand_wcpay_request:ok") {
                        alert("支付成功！稍后会将确认邮件发送至您的邮箱。并根据您的信息开具发票，于会议期间发放。");
                        window.location.href = '/';
                    } else {
                        alert("支付失败！");
                        debugger;
                        window.history.back();
                    }
                }
            );

    }
    if (typeof WeixinJSBridge == "undefined"){
        if( document.addEventListener ){
            document.addEventListener('WeixinJSBridgeReady', onBridgeReady, false);
        }else if (document.attachEvent){
            document.attachEvent('WeixinJSBridgeReady', onBridgeReady);
            document.attachEvent('onWeixinJSBridgeReady', onBridgeReady);
        }
    }else{
        onBridgeReady();
    }
</script>